//
// Created by Martin on 2021/10/25.
//
#include <iostream>
#include <stack>
#include <string>

using namespace std;
int main()
{
    stack<string> backward;
    stack<string> forward;
    string cur = "http://www.acm.org/";
    string c;

    /*
     * e.g. input: VISIT http://acm.ashland.edu/
     * command means VISIT
     * URL means "http://acm.ashland.edu/"
     */
    while (cin >> c && c != "QUIT") {
        if (c == "VISIT") {
            backward.push(cur);
            cin >> cur;
            cout << cur << endl;

            while (!forward.empty()) {
                forward.pop();
            }
        }
        else if (c == "BACK") {
            if (backward.empty()) {
                cout << "Ignored" << endl;
            }
            else {
                forward.push(cur);
                cur = backward.top();
                backward.pop();
                cout << cur << endl;
            }
        }
        else {
            if (forward.empty()) {
                cout << "Ignored" << endl;
            }
            else {
                backward.push(cur);
                cur = forward.top();
                forward.pop();
                cout << cur << endl;
            }
        }
    }

    return 0;
}
